package com.hh.workorder.repository;

import com.hh.workorder.entity.RepairWorkOrder;
import com.hh.workorder.repository.RepairWorkOrderSpecification;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface RepairWorkOrderRepository extends JpaRepository<RepairWorkOrder, Integer>, JpaSpecificationExecutor<RepairWorkOrder> {

    default List<RepairWorkOrder> searchRepairWorkOrders(String id_like, String title_like, String status, String device_like, String assignee, String startDate, String endDate) {
        RepairWorkOrderSpecification specification = new RepairWorkOrderSpecification(id_like, title_like, status, device_like, assignee, startDate, endDate);
        return findAll(specification);
    }
}